package view;

import java.io.File;
import java.util.HashMap;

import game.Bishop;
import game.King;
import game.Knight;
import game.Pawn;
import game.Piece;
import game.Queen;
import game.Rook;
import game.Team;

import javax.swing.ImageIcon;

/**
 * <p>A 'special' set of icons for a game of chess.</p>
 * 
 * @author Mark Kelly
 * @version 3.0
 *
 */
public class SpecialKnightIcons implements ChessIcons {

	private static final String ICON_PATH = "images" + File.separator + "SpecialKnightIcons" + File.separator;

	private static final String ICON_EXTENSION = ".gif";
	
	/**
	 * <p>The collection of icons for the white Pieces.</p>
	 */
	private static final HashMap<Class<? extends Piece>,ImageIcon> whitePieces;
	static {
		HashMap<Class<? extends Piece>,ImageIcon> aMap = new HashMap<Class<? extends Piece>,ImageIcon>();
		aMap.put(Pawn.class, new ImageIcon(ICON_PATH + Team.WHITE + " " + "P" + ICON_EXTENSION));
		aMap.put(Rook.class, new ImageIcon(ICON_PATH + Team.WHITE + " " + "R" + ICON_EXTENSION));
		aMap.put(Knight.class,new ImageIcon(ICON_PATH + Team.WHITE + " " + "N" + ICON_EXTENSION));
		aMap.put(Bishop.class, new ImageIcon(ICON_PATH + Team.WHITE + " " + "B" + ICON_EXTENSION));
		aMap.put(Queen.class, new ImageIcon(ICON_PATH + Team.WHITE + " " + "Q" + ICON_EXTENSION));
		aMap.put(King.class, new ImageIcon(ICON_PATH + Team.WHITE + " " + "K" + ICON_EXTENSION));
		whitePieces = aMap;
	}
	
	/**
	 * <p>The collection of icons for the black Pieces.</p>
	 */
	private static final HashMap<Class<? extends Piece>,ImageIcon> blackPieces;
	static {
		HashMap<Class<? extends Piece>,ImageIcon> aMap = new HashMap<Class<? extends Piece>,ImageIcon>();
		aMap.put(Pawn.class, new ImageIcon(ICON_PATH + Team.BLACK + " " + "P" + ICON_EXTENSION));
		aMap.put(Rook.class, new ImageIcon(ICON_PATH + Team.BLACK + " " + "R" + ICON_EXTENSION));
		aMap.put(Knight.class,new ImageIcon(ICON_PATH + "THE other black knight" + ICON_EXTENSION));
		aMap.put(Bishop.class, new ImageIcon(ICON_PATH + Team.BLACK + " " + "B" + ICON_EXTENSION));
		aMap.put(Queen.class, new ImageIcon(ICON_PATH + Team.BLACK + " " + "Q" + ICON_EXTENSION));
		aMap.put(King.class, new ImageIcon(ICON_PATH + Team.BLACK + " " + "K" + ICON_EXTENSION));
		blackPieces = aMap;
	}
	
	/**
	 * {@inheritDoc}
	 */
	public ImageIcon getIconForPiece(Piece p) {
		return ((p.getTeam() == Team.WHITE) ? whitePieces : blackPieces).get(p.getClass());
	}

}
